import { Injectable } from '@nestjs/common';
import { AppMapping } from './app.mapping';
import { CreatePool, Transactional } from 'decorator-mysql';

@Injectable()
export class AppService {
  constructor(private readonly appMapping: AppMapping) { }

  @Transactional()
  async deleteUserById(@CreatePool() pool: any) {
    // 传递一个连接池进去
    await this.appMapping.deleteUserById.apply(pool)

    await this.appMapping.deleteUserById.apply(pool)

    // 报错自动回滚
    throw new Error("error");

  }
}
